<?php
class System_Model_Modules extends Promotor_Model_Abstract {

	/**
	 * @param string $module
	 * @return void
	 */
	public function enabledDisable($module) {
		 $modules = Admin_Model_Modules::getInstance();

		 // zmiana statusu modułu
		 if ($modules->isEnabled($module)) {
		 	$modules->setDisable($module);
		 } else {
		 	$modules->setEnable($module);
		 }

		 $status = $modules->getStatus();
		 
		 $this->_setStatus($status);
		 $this->_addMessages($modules->getMessages());

		 if ($status === self::FAILURE) {
		 	return;
		 }
		 
		 // generowanie konfiguracji
		 
		 $appConfiguration = new Admin_Model_AppConfiguration();
		 $appConfiguration->saveForFrontcontrollerControllerDirecotry();

		 $this->_addMessage('Admin_Model_AppConfiguration::saveForFrontcontrollerControllerDirecotry');
		 
		 $this->_addMessage($appConfiguration->getStatus());
		 $this->_addMessages($appConfiguration->getMessages());
	}
}